from django.conf.urls.defaults import *
from django.conf import settings
from django.contrib import admin
from forca.models import Professor, Disciplina, RegistroII
admin.autodiscover()

prof = {'queryset': Professor.objects.all(),
		'template_name': "listaprof.html",
		'template_object_name': "lista_prof"}
disc = {'queryset': Disciplina.objects.all(),
		'template_name': "listadisc.html",
		'template_object_name': "lista_disc"}

registro = {'form_class': RegistroII, 'template_name': "registrar.html", 'success_url': "/registro/ok"}

urlpatterns = patterns('',
	(r'^admin/doc/', include('django.contrib.admindocs.urls')),
	(r'^admin/(.*)', admin.site.root),
)

urlpatterns += patterns('django.views.generic',
	(r'^$', 'simple.direct_to_template', {'template': 'index.html'}),
	(r'^registro/ok/$', 'simple.direct_to_template', {'template': 'registrar_ok.html'}),
	(r'^disciplina/$', 'list_detail.object_list', disc),
	(r'^professor/$', 'list_detail.object_list', prof),
)

urlpatterns += patterns('forca.views',
	(r'^avaliar/$', 'avaliacao'),
	(r'^disciplina/(?P<coddisc>(?:[A-Z][A-Z][A-Z]|[a-z][a-z][a-z])[0-9][0-9][0-9][0-9][0-9])/$', 'disciplina'),
	(r'^professor/(?P<nomeprof>[a-z]+)/$', 'professor'),
	#(r'^usuario/$', 'userpage', {'user': None}),
	#(r'^usuario/(?P<user>\w+)/$', 'userpage'),
)

urlpatterns += patterns('django.contrib.auth.views',
	(r'^login/$', 'login', {'template_name': 'login.html'}),
	(r'^logout/$', 'logout', {'template_name': 'index.html'}),
)

urlpatterns += patterns('registration.views',
	(r'^registro/$', 'register', registro),
	(r'^registro/ativar/$', 'activate', {'template_name': 'ativacao.html'}),
)

if settings.DEBUG:
	urlpatterns += patterns('', (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': 'static/'}))